<%--
  Created by IntelliJ IDEA.
  User: 和盈
  Date: 2020/7/31
  Time: 11:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script src="/js/jquery.js"></script>
    <script>
        $(function () {
            $("[type=button]").click(function () {
                var formData=new FormData();
                var name=$("#username").val();
                var f=$("[type=file]")[0].files[0];
                formData.append("username",name);
                formData.append("f",f);
                $.ajax({
                    url:"/file/upload",
                    type:'post',
                    data:formData,
                    processData:false,
                    contentType:false,
                    success:function (data) {
                        //alert(data);
                        location.reload();
                    }
                });
            });
        });

    </script>
</head>
<body>
    <form action="/file/upload" method="post" enctype="multipart/form-data">
        <input type="file" name="f" placeholder="文件"><br>
        <input name="username" id="username" placeholder="user"><br>
        <input type="submit" value="提交">
    </form>
    <input type="button" value="FormData提交">
    <image  style="width:300px;height:300px;" src="${url}" class="img"/>

</body>
</html>
